package com.i2f.i2msk.impl;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.i2f.i2msk.Keyboard;
import com.i2f.i2msk.enums.KeyboardEnum;
import com.i2f.i2msk.img.KeyboardImg;

public class NumberKeyboard extends Keyboard{
	

	/**
	 * 
	 */
	private static final long serialVersionUID = 3662628393546263525L;
	private List<Integer> randomKey;

	public NumberKeyboard(KeyboardEnum keyboardEnum)  {
		super(keyboardEnum);
		randomKey=new ArrayList<Integer>(Keyboard.numberKey);
		if(keyboardEnum == KeyboardEnum.NUMBER_DISORDER_RSA || keyboardEnum == KeyboardEnum.NUMBER_DISORDER_SM2 ){
			Collections.shuffle(randomKey);
		}
	}

	@Override
	public String getKeyboardImage() {
		
		StringBuilder sb;
		try {
			sb = new StringBuilder(KeyboardImg.createNumberKeyboard(randomKey));
			sb.append(";$;");
			sb.append(encryptionUtil.encoder(randomKey));
			return sb.toString();
		} catch (IOException e) {
			throw new RuntimeException("键盘图片文件错误。无法读取",e);
		}
		
	}
}
